import Local.Date.Time.DateTime;

public class ExceptionAndLocalDateTime {
    public static void main(String[] args) {

        int[] array = { 0 };
        int index = 10;

        try {
            int back = exampleException(array, index);
            System.out.println("数字为：" + back);
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
            System.out.println("数组越界");
        }catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("空指针");
        }
        System.out.println("程序继续");

        DateTime dateTime = new DateTime();
        dateTime.example();
    }

    static int exampleException(int[] array, int index) {
        if (array == null) {
            throw new NullPointerException("数组为空");
        }
        if (index < 0 || index >= array.length) {
            throw new ArrayIndexOutOfBoundsException("下标越界");
        }

        return array[index];
    }
}
